import java.util.Stack;

public class MyStack1{
	private Stack<Integer> dataStack;
	private Stack<Integer> minStack;

	public MyStack1(){
		this.dataStack = new Stack<Integer>();
		this.minStack = new Stack<Integer>();
	}

	public void push(int newNum){
		if( this.minStack.isEmpty() ){
			this.minStack.push(newNum);
		} else if( newNum <= this.getMin() ){
			this.minStack.push(newNum);
		}
		this.dataStack.push( newNum );
	}

	public int pop(){
		if( this.dataStack.isEmpty() ){
			throw new RuntimeException("Your stack is empty");
		}
		int value = this.dataStack.pop();
		if( value == this.getMin() ){
			this.minStack.pop();
		}
		return value;
	}

	public int getMin(){
		if( this.minStack.isEmpty() ){
			throw new RuntimeException("Your stack is empty");
		}
		return this.minStack.peek();
	}
}
